package com.detech.sbmh.base.exception;

/**
 * 业务异常
 */
public final class ServiceException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private Integer code;
    /**
     * 信息提示
     */
    private String message;

    /**
     * 业务数据
     */
    private Object data;

    /**
     * 空构造方法，避免反序列化问题
     */
    public ServiceException() {
    }

    public ServiceException(String message) {
        this.message = message;
    }

    public ServiceException(String message, Object data) {
        this.message = message;
        this.data = data;
    }

    public ServiceException(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public ServiceException setMessage(String message) {
        this.message = message;
        return this;
    }

    public ServiceException setData(Object data) {
        this.data = data;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
